/**
 * FileFind - ftp/shares indexing and search php engine
 * Module: agent-java
 * Description: Agent written in java language
 * Copyright (c) 2003-2010 Rage Steel, www.gt2.ru
 * ----------------------------------------------
 * $Id$
 */
package ru.ffind.agent.io;

import java.io.File;
import java.io.IOException;

/**
 * 
 * Miscellaneous file tools
 *
 * @author Rage Steel
 *
 */
public class FileTools {

	private FileTools() {
        // Private constuctor to disallow creating of instance
	}
	
	/**
	 * Symlinks detector 
	 * Inpired by http://www.idiom.com/~zilla/Xfiles/javasymlinks.html
	 * 
	 * @param file file to look
	 * @return true if link or file does not exists
	 */
	public static boolean isLink(File file) throws IOException {
		if (!file.exists()) {
			return true;
		} else {
			File canonical = file.getCanonicalFile();
			File absolute = file.getAbsoluteFile();
			return !absolute.equals(canonical);
		}
	}
}
